package parser

import (
	"regexp"

	"../../../crawler/engine"
)

const CityListRe = `<a href="(http://www.zhenai.com/zhenghun/\w+)"[^>]*?>(.*?)</a>`

func ParseCityList(contents []byte) engine.ParseResult {
	compile := regexp.MustCompile(CityListRe)
	matches := compile.FindAllSubmatch(contents, -1)

	result := engine.ParseResult{}
	for _, m := range matches {
		result.Items = append(result.Items, string(m[2]))
		result.Requests = append(result.Requests, engine.Request{Url: string(m[1]), ParserFunc: engine.NilParse})
	}
	return result
}
